﻿using Ekton_Manage_DomainAbstractions;
using Ekton_Manage_InfrastructureCore.Common;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Ekton_Manage_InfrastructureCore.Repositories
{
    public interface IBaseRepository<T, TKey> : IDisposable where T : Entity<TKey>
    {

        /// <summary>
        /// 删除数据集合
        /// </summary>
        /// <param name="DataId"></param>
        /// <returns></returns>
        Task<bool> DeleteArray(List<TKey> DataId);

        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        Task<bool> InsertManyData(List<T> Data);

        /// <summary>
        /// 根据id查询单条数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> QuerySingleData(TKey id);


        /// <summary>
        /// 根据id查询单条数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> QuerySingleData(string id);

        /// <summary>
        /// 查询单条数据
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<T> QuerySingleData(Expression<Func<T, bool>> expression);

        /// <summary>
        /// 删除单条数据 
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        Task<bool> DeleteSingleData(TKey id);


        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="Object"></param>
        /// <returns></returns>
        Task<Tuple<bool, int>> UpdateSingleData(T Object);

        Task<Tuple<bool, int>> UpdateManyData(List<T> Data);

        /// <summary>
        /// 添加单条数据
        /// </summary>
        /// <param name="Object"></param>
        /// <returns></returns>
        Task<Tuple<bool, int>> InsertSingleData(T Object);

        /// <summary>
        /// 单表/视图分页查询
        /// </summary>
        /// <param name="queryDataParame"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<Tuple<List<T>, int>> QueryPageData(QueryDataParame queryDataParame, Expression<Func<T, bool>> expression);
        Task<Tuple<List<T>, int>> QueryPageData(QueryDataParame queryDataParame, Expression<Func<T, bool>> expression, Func<T, dynamic> sort);
        /// <summary>
        /// 查询单表
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<List<T>> QueryTableList(Expression<Func<T, bool>> expression);

        /// <summary>
        /// 查询数量
        /// </summary>
        Task<int> QueryCount(Expression<Func<T, bool>> expression);

    }
}
